package com.qf;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @author fy
 * @version V1.0
 * @Project workspace
 * @Package com.qf
 * @Description:
 * @Date 2022/7/6 17:03
 */
@SpringBootApplication
@EnableEurekaClient
//开启feign远程调用，并扫描feign接口
@EnableFeignClients(basePackages = "com.qf.feign")
public class ConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class, args);

    }

    /**
     * 初始化restTemplate
     * @return
     */
    @Bean
    //给远程调用对象加入接口负载均衡技术，默认轮询策略
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}
